﻿using System.Collections.Generic;
using HK.Core.Common;
using HK.Core.Serializable.Protocol.Data;
using UnityEngine;

namespace HK.Core.Load.Protocol.Data
{
    
    /// <summary>
    /// Bundle type.
    /// </summary>
    public enum BundleType 
    {
        /// <summary>
        /// 无
        /// </summary>
        None,
        /// <summary>
        /// 一般.
        /// </summary>
        Normal,
        /// <summary>
        /// 场景.
        /// </summary>
        Scene
    }
    
    /// <summary>
    /// 接口 : Ab信息
    /// </summary>
    public interface IAbInfo : IAssetBase
    {
        /// <summary>
        /// AssetBundle Id
        /// <para>* 为所属AB包名，若非是从Ab包加载而来的，则为null</para>
        /// </summary>
        string AbId { get; }
        
        /// <summary>
        /// Ab类型.
        /// </summary>
        BundleType AbType { get; }
        
        /// <summary>
        /// AssetBundle
        /// </summary>
        AssetBundle Ab { get; }
        
        /// <summary>
        /// AssetBundle的主Manifest标志位
        /// </summary>
        bool MainManifest { get; }
        
        /// <summary>
        /// 设定Entity
        /// </summary>
        /// <param name="iType">Ab类型</param>
        /// <param name="iAb">Ab</param>
        /// <param name="iMainManifest">AssetBundle的主Manifest标志位</param>
        void SetAb(BundleType iType, AssetBundle iAb, bool iMainManifest = false);
        
        /// <summary>
        /// 默认资源标志位
        /// </summary>
        bool IsDefault { get; }
        
        /// <summary>
        /// Ab卸载时，全部Unload标志位
        /// </summary>
        bool UnloadAll { get; }
        
        /// <summary>
        /// 数据大小(单位：Byte)
        /// </summary>
        long DataSize { get; }
        
        /// <summary>
        /// 版本号
        /// </summary>
        ISAssetVersion Version { get; }

        /// <summary>
        /// 设定信息
        /// </summary>
        /// <param name="iAbId">AbId</param>
        /// <param name="iOptions">选项</param>
        /// <param name="iAsync">异步标志位</param>
        /// <param name="iUnloadAll">Ab卸载时，是否全部卸载标志位</param>
        /// <param name="iCoolTime">倒计时冷却时间(默认 : 30秒)</param>
        void SetInfo(string iAbId, int iOptions, bool iAsync = false,
            bool iUnloadAll = false, float iCoolTime = Const.DefaultCoolTime);
        
        /// <summary>
        /// 依赖列表<BR/>
        /// * 用以反向索引所属依赖关系用
        /// </summary>
        List<IAbInfo> Depends { get; }

        /// <summary>
        /// 更新依赖信息
        /// </summary>
        /// <param name="iDepends">依赖列表</param>
        void UpdateDepends(List<IAbInfo> iDepends);

    }
}